﻿
@{
    ViewBag.Title = "打印返修品入库单";
    Layout = "~/Views/Shared/_Form.cshtml";
}
<script src="~/Content/js/jqprint/jquery.jqprint-0.3.js"></script>
<script src="~/Content/js/qrcode/qrcode.js"></script>
<link href="~/Content/css/PrintCss/PrintStockIn.css" rel="stylesheet" media="print" />

<style type="text/css">
body{background:#ddd;}
body,ul,li,div{list-style:none;margin:0;padding:0;}
ul li{float:left;overflow:hidden;}
label{margin-left:5px;}

.content {position: relative;margin: 0 auto;width: 800px;background:#fff;height: 600px;}
.content div{height:34px;}
.content .header{position:relative;width:780px;margin:12px auto 0 auto;height:45px;}
.header .item{overflow: hidden;position: absolute ;font-family:"宋体"; font-size: 10pt;  width:162px;height:21px;}
.title {font-size: 16px;text-align: center;padding-top:10px;padding-right:40px;}
table{border-collapse: collapse;border:1px solid #000;width: 780px;margin: 0 auto;}

table th{border:1px solid #000;color:#202020;font-size:12px;text-align:center;}
table td{border:1px solid #000;color:#202020;font-size:12px;margin-left:5px;}
table .number{text-align:right;}
.footer{width: 780px;margin: 10px auto 0;}
.footer span{font-size:12px;}
</style>

<script>
    var data = $.request("data");
    var flag = $.request("flag");
    var oldtemplet = "";
    $(function () {
        oldtemplet=$("#templet").html();
        var docnoArr = data.split(',');
        $.each(docnoArr, function (index, value) {
            getPrintData(value);
        });
        top.$(".content-iframe").css("background-color", "#f9f9f9");
    })
    function btn_print() {
        $("#print").jqprint();
    }
    function getPrintData(fdocuNO) {
        var url = "/VBaseData/V_CPK_42_MX_StoCPKListAcco/GetInStockInfo";
        if (flag == "arc") {
            url = "/VBaseData/V_CPK_45_HZ_StoCPKListAcco_Mid/StoInCPKMidListForPrint";
        }
        $.GetData({
            url: url,
            param: { fdocuno: fdocuNO },
            success: function (data) {
                var rowindex = 1;
                var totalFQuantity_KP=0;
                var totalFQuantity = 0;
                var totalFMoney_Settle = 0;
                var totalFContainerQuantity = 0;
                var totalFPalletQuantity = 0;
                var jsondata = JSON.parse(data.data);
                var jsondataLength = $.josnLength(jsondata);
                $("#templet").html(oldtemplet);
                $.each(jsondata, function (index, value) {
                    var html = $("#templet .header").html().format(value);
                    $("#templet .header").html(html.replace("null", ""));
                    var row = $("#templet table tbody").html().format(value);
                    $("#templet .content table").append(row.replace("null", ""));
                    totalFQuantity_KP += value.FQuantity_KP;
                    totalFQuantity += value.FQuantity;
                    totalFMoney_Settle += value.FMoney_Settle;
                    totalFContainerQuantity += value.FContainerQuantity;
                    totalFPalletQuantity += value.FPalletQuantity;
                    rowindex++;
                    if (rowindex % 13 == 0 || (jsondataLength + 1) == rowindex) {
                        var rowdata = { FProductionName: "合计:", FQuantity_KP: totalFQuantity_KP, FQuantity: totalFQuantity, FMoney_Settle: totalFMoney_Settle, FContainerQuantity: totalFContainerQuantity, FPalletQuantity: totalFPalletQuantity, FProductionNO: "", FPrice_Settle: "", FContainerNO: "", FPalletNO: "", FDescription:"" };
                        var totalrow = $("#templet table tbody").html().format(rowdata);
                        $("#templet .content table").append(totalrow.replace("件", ""));
                    }
                });
                $("#print").append($("#templet .content").prop("outerHTML")).append("<h1></h1>");
                $.barcode("#barcode" + fdocuNO, fdocuNO);
                $.makeQrCode("qrcode" + fdocuNO, fdocuNO);
            }
        });
    }
    function btn_Return() {
        parent.$.detailClose();
    }
</script>
<div style="position: absolute; top: 22px; right: 8px;">
    <a class="btn btn-default " onclick="btn_print()"><i class="fa fa-print" style="margin-right: 5px; font-size: 13px;"></i>直接打印</a>
    <a class="btn btn-default " onclick="btn_Return()"><i class="fa fa-print" style="margin-right: 5px; font-size: 13px;"></i>返回</a>
</div>

<div id="templet" style="display:none;">
    <table>
        <tbody>
            <tr>
                <td>{FProductionNO}</td>
                <td>{FProductionName}</td>
                <td class="number">{FQuantity_KP}</td>
                <td class="number">{FQuantity}</td>
                <td style="text-align:center;">件</td>
                <td class="number">{FPrice_Settle}</td>
                <td class="number">{FMoney_Settle}</td>
                <td>{FContainerNO}</td>
                <td class="number">{FContainerQuantity}</td>
                <td>{FPalletNO}</td>
                <td class="number">{FPalletQuantity}</td>
                <td>{FDescription}</td>
            </tr>
        </tbody>
    </table>
    <div class="content">
        <div class="title" style="height: 32px;">北汽福田汽车股份有限公司冲压工厂</div>
        <div class="header">
            <div class="item" style="top: 0px;">交出单位:</div>
            <div class="item" style="top: 0px;left: 60px;">{FProCompanyName}</div>
            <div class="item" style="top: 20px;">收入单位:</div>
            <div class="item" style="top: 20px;left: 60px;">{FSupplierName}</div>
            <div class="item" style="left: 240px;top: 24px;">交出日期:</div>
            <div class="item" style="left: 300px;top: 24px;">{FCurDate}</div>
            <div class="item" style="top: 24px;left: 440px;">凭证编号:</div>
            <div class="item" style="left: 500px;top: 24px;">{FCredence}</div>
            <div class="item" style="left: 600px;top: 24px;">单据编号:</div>
            <div class="item" style="left: 660px;top: 24px;">{FDocuNO}</div>

            <div class="item" style="left: 510px;top: -50px;width: 180px;height: 60px;"><img id="barcode{FDocuNO}" alt="img" style="height:60px;width:180px;"></div>

            <div class="item" style="left: 310px;top: -20px;font-size: 24px;height: 60px;width: 200px;font-weight: bold;">返修品入库单</div>
            <div class="item" style="width: 65px;height: 65px;left: 710px;top: -45px;">
                <div class="qrcode" id="qrcode{FDocuNO}"></div>
            </div>

        </div>

        <table>
            <tr>
                <th style="width: 100px;">零件编号</th>
                <th style="width: 150px;">零件名称</th>
                <th style="width: 35px;">交出数量</th>
                <th style="width: 35px;">实际数量</th>
                <th style="width: 30px;">单位</th>
                <th style="width: 50px;">单价(元)</th>
                <th style="width: 70px;">金额(元)</th>
                <th style="width: 80px;">容器编号</th>
                <th style="width: 35px;">容器数量</th>
                <th style="width: 80px;">托盘编号</th>
                <th style="width: 35px;">托盘数量</th>
                <th>备注</th>
            </tr>
        </table>

        <div class="footer">
            <span>制表人:</span>
            <span>超级管理员</span>
            <span style="margin-left: 20px;">2017-08-15 16:01:54</span>
            <span style="margin-left: 50px;">验收员:</span>
            <span style="margin-left: 80px;">库管员:</span>
            <span style="margin-left: 60px;">送货员:</span>
        </div>
    </div>
 </div>
    <div id="print">
       
    </div>
